<div class="row">
<div class="button-container mb10">
	
</div>
<table class="table table-bordered table-striped">
	<thead>
		<tr>
			<th style="width: 80px;"><input type="checkbox" class="btn_all" /> <?php echo $this->_attributeLabels['aid'] ?></th>
			<th><?php echo $this->_attributeLabels['filename'] ?></th>
			<th style="width:80px;"><?php echo $this->_attributeLabels['size'] ?></th>
			<th style="width:150px;"><?php echo $this->_attributeLabels['dateline'] ?></th>
            <th style="width:100px;"><?php echo $this->_attributeLabels['type'] ?></th>
			<th style="width:100px;">管理操作</th>
		</tr>
	</thead>
	<tbody>
        <?php
        if( !empty($list) ){
            foreach($list as $aVal){
            ?>
        <tr>
            <td><input type="checkbox" class="ids" name="ids[]" value="<?php echo $aVal['aid'] ?>" /><?php echo $aVal['aid'] ?></td>
            <td><?php echo $aVal['filename'] . ($aVal['isuse']==1 ? '' : '<i class="red">-未使用</i>'); ?></td>
            <td><?php echo Yii::app()->common->formatnumber($aVal['size']/1024 ,2) .'KB'; ?></td>
            <td><?php echo Yii::app()->common->formattime('Y-m-d H:i:s' ,$aVal['dateline'])  ; ?></td>
            <td><?php echo $aVal['type'] ?></td>
            <td>
            <?php
                echo CHtml::link('预览' ,$aVal['filepath'] ,array('target'=>'_blank'));
                echo "\n";
                echo Yii::app()->user->checkAccess('attachment|deldete') ? 
                     CHtml::link('删除' ,'javascript:void(0);' ,array('url'=>$this->createUrl('attachment/delete' ,array('aid'=>$aVal['aid'])) ,'class'=>'delete')) : '';
            ?>
            </td>
        </tr>
            <?php    
            }
        }
        ?>
        
    </tbody>
</table>
<div class="table-bottom-operate">
    <div class="inline pull-left table-operate">
        <?php echo Yii::app()->user->checkAccess('attachment|deleteall')?CHtml::link('批量删除','javascript:void(0);',array('class'=>'button button-primary deleteall','url'=>$this->createUrl('attachment/deleteall'))):'';?>
    </div>
    <div class="inline pull-right page">
        <?php $this->widget('LinkPager',array('pages' => $pages)); ?>
    </div>
</div>
</div>
<script type="text/javascript">
$('.iframedelete').bind('click' ,function(){
    var self = $(this);
   parent.parent.jsconfirm("确定要删除吗？" ,
			function(){
				$.getJSON(self.attr('url'),function(data){alert(1234);
					if(data.err==0){
					    //SendWebMsg('success', data.msg);
						data.url ? window.location.href=data.url : $(self).parent().parent().remove();                        
						//ts('删除成功');
					}else{
						parent.parent.jsshow(data.msg,'','error');
					}
				})
			} ,'info'); 
});
//批量删除
$('.iframedeleteall').click(function(){
	var checked=$('.ids:checked') ,self = $(this);
	
	if(checked.length>0){
		parent.parent.jsconfirm('确定要批量删除数据吗？' ,
			function(){
				var arr=new Array();
				$(".ids:checked").each(function(){
					arr.push($(this).val());
				});
				value_str=arr.join('|');
				$.post(self.attr('url'),{ids:value_str},function(data){
					var myObject = eval('(' + data + ')');
					if(myObject.err==0){
					    //SendWebMsg('success', data.msg);  
						checked.parent().parent().remove();
						//ts('删除成功');
					}else{
						parent.parent.jsshow(data.msg,'','error');
					}
				})
			} ,'info');
			
	}else{
		parent.parent.jsshow('请选择要操作的选项','','error');
	}
	return false;
 });
</script>